//
//  LXApplyPicCollectionCell.h
//  ZuLinProject
//
//  Created by bancheng on 2021/12/24.
//  Copyright © 2021 LX_App. All rights reserved.
//

#import "LXApplyPicCollectionCell.h"

@implementation LXApplyPicCollectionCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        
        self.imgV = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imgV];
        self.imgV.contentMode = UIViewContentModeScaleToFill;
        [self.imgV addCorner:5];
        [self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@12.5);
            make.top.equalTo(@10);
            make.right.equalTo(@-12.5);
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
        }];
        
        self.imgV.userInteractionEnabled = YES;
        
        UITapGestureRecognizer *tapImg = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(extendPhoto)];
        [self.imgV addGestureRecognizer:tapImg];
        
        
        self.takeImgV = [[UIImageView alloc]init];
        [self.contentView addSubview:self.takeImgV];
        self.takeImgV.image = [UIImage imageNamed:@"takePicture"];
        [self.takeImgV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@26.5);
            make.height.equalTo(@22);
            make.center.equalTo(self.imgV);
        }];
        
        
        
        self.deleteImg = [[UIImageView alloc]init];
        [self.contentView addSubview:self.deleteImg];
        self.deleteImg.image = [UIImage imageNamed:@"圆形删除"];
        
        [self.deleteImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.imgV).offset(5);
            make.top.equalTo(@0);
            make.width.equalTo(@20);
            make.height.equalTo(@20);
        }];
        
        self.deleteImg.userInteractionEnabled = YES;
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(deletePhoto)];
        [self.deleteImg addGestureRecognizer:tap];
        
    }
    return self;
}

- (void)deletePhoto{
    if (_deleteImgBlock) {
        _deleteImgBlock();
    }
}

- (void)extendPhoto{
    
    
    if (_extendImgBlock) {
        _extendImgBlock(self.imgV);
    }
    
    
    if (_tapImgCell) {
        _tapImgCell();
    }
}

@end
